// pages/my.js
var session = require('../../common/session')
Component({
  data: {
    wechatUserInfo: null,
    hideTabBar: null,
    statusBarHeight: 20,
    fontSizeSetting: 24
  },

  pageLifetimes: {
    show() {
      let that = this;
      let hideTabBar = session.get('xyznzzwechathideTabBar');
      if(hideTabBar) {
        this.setData({
          hideTabBar:hideTabBar
        })
        this.getTabBar().setData({
          show:false
        });
      } else if (typeof this.getTabBar === 'function' && this.getTabBar()) {
        this.getTabBar().setData({
          selected: 1
        });
      }
      var _wechatUserInfo = session.get('xyznzzwechatUserInfo');
      this.setData({
        wechatUserInfo: _wechatUserInfo
      });
      wx.setNavigationBarTitle({
        title: '我的'
      });
      wx.getSystemInfo({
        success(res){
          that.setData({
            statusBarHeight: res.statusBarHeight,
            fontSizeSetting: res.fontSizeSetting
          });
        }
      });
    }
  },
  methods: {
    openToReviewed: function(){
      wx.navigateTo({
        url: '../toBeReviewed/toBeReviewed',
      });
    },
    openReviewed:function(){
      wx.navigateTo({
        url: '../Reviewed/Reviewed',
      });
    },
    backOne: function(){
      let identity = session.get('xyznzzwechatIdentity');
      wx.redirectTo({
        url: '../operation/operation?identity='+identity
      });
    },
    logoutFun: function(){
      wx.showModal({
        title: '确定退出当前账号吗？',
        content: '',
        success (res) {
          if (res.confirm) {
            session.set('xyznzzaccessToken', '');
            session.set('xyznzzbusiness', '');
            session.set("xyznzzwechatUserInfo",'');
            wx.redirectTo({
              url: '../syslogin/syslogin'
            })
          }
        }
      })
    }
  }
})
